package com.xukang.demo.controller;


import com.xukang.demo.entity.ProjectInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;

/**
 * SpringBoot 2.0 第一个程序
 */
@RestController
public class HelloController {

    @Value("${server.port}")
    private String port;

    @RequestMapping("/getInfo")
    public ProjectInfo getInfo (){
        ProjectInfo info = new ProjectInfo() ;
        info.setTitle("SpringBoot 2.0 基础教程");
        info.setDate("2019-06-05");
        info.setAuthor("端口为"+port);
        return info;
    }

    /**
     * 模拟feign 调用时  超时
     * @return
     */
    @RequestMapping("/getInfoTimeout")
    public ProjectInfo getInfoTimeout (){
        try {
            Thread.sleep(1500);  //延迟1.5秒
        }catch (Exception e){
        }
        ProjectInfo info = new ProjectInfo() ;
        info.setTitle("SpringBoot 2.0 基础教程");
        info.setDate("2019-06-05");
        info.setAuthor("端口为"+port);
        return info;
    }
}
